<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>comment</title>
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
</head>

<body>
    <div class="layui-container">
        <div class="layui-row">
            <div class="layui-col-lg-offset3" layui-col-lg6>
                <div class="layui-form layuimini-form">
                    <form class="layui-form" action="" lay-filter="userForm">

                        <div class="layui-form-item">
                            <label class="layui-form-label">本人ID</label>
                            <div class="layui-input-block">
                                <input type="text" name="user_id" required lay-verify="required" placeholder="请输入本人ID" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label required" >评价内容</label>
                            <div class="layui-input-block">
                                <input type="text" name="content" lay-verify="required" placeholder="请输入评价内容" value="" class="layui-input">
                            </div>
                        </div>

                        <!-- <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label required" >时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="datetime" id="date" lay-verify="date" placeholder="yyyy-MM-dd"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div> -->

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>



    <script>
        //Demo
        layui.use(['upload', 'element', 'form'], function() {
            var form = layui.form,
                $ = layui.jquery,
                upload = layui.upload,
                element = layui.element,
                laydate = layui.laydate;


            //监听提交
            form.on('submit(formDemo)', function(data) {
                //layer.msg(JSON.stringify(data.field));
                $.ajax({
                    "url": "http://localhost:8080/comment/add",
                    "data": data.field,
                    "success": function(result) {
                        if (result.code == 200) {



                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);


                        } else {
                            layer.msg(result.msg);
                        }
                    }
                });

                return false;
            });
        });
    </script>


</body>

</html>